﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ZhuXingFamilys.MainViewModel
{
    public class DataProcessor
    {
        public static T ToValue<T>(DataRow dr, string columnName, T defValue)
        {
            if (dr.Table.Columns.Contains(columnName) == true)

            {

                if (dr[columnName] != DBNull.Value && string.IsNullOrWhiteSpace(dr[columnName].ToString()) == false)

                {

                    return (T)(Convert.ChangeType(dr[columnName], typeof(T)));

                }


            }
            return defValue;
        }
    }
}
